{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "15a4c593",
   "metadata": {},
   "source": [
    "# Playing with Batchnorm without any training...\n",
    "\n",
    "How do you explain these figures?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ca7ca78d",
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import torch\n",
    "from torch import nn\n",
    "\n",
    "torch.manual_seed(42);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "88ceb159",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAYZElEQVR4nO3df3BUZZ7v8ffXgER+XH5mKSR4g7OU6AAJECOKP7hy9SpOCSo6jowSlxlqtpytdWrXWRyrvNGypphbrA4Wt7QyowNMqRNlV02ptS7+oJRBccLIKAx6id5YCYPAhB+rI4jod//oJ9kG86OTdPfpPHxeVV055zmnu785dD48/fTp55i7IyIicTkl6QJERCT7FO4iIhFSuIuIREjhLiISIYW7iEiEBiRdAMCYMWO8rKws6TJERPqVLVu2/NndSzraVhDhXlZWRkNDQ9JliIj0K2b2UWfbNCwjIhIhhbuISIQU7iIiESqIMXcR6Z0vvviClpYWjhw5knQpkkPFxcWUlpYycODAjO+jcBfpx1paWhg2bBhlZWWYWdLlSA64O62trbS0tDBx4sSM76dhGZF+7MiRI4wePVrBHjEzY/To0T1+d6ZwF+nnFOzx682/scJdRCRCGnMXiUjZsuez+nhNy6/qdp8LLriATZs2Zfd5m5rYtGkTN910U4fb77jjDl544QXmzZvHN77xDQYPHswtt9yS0WNv3bqVP/3pT8ybN+9r21avXk1DQwOrVq3KuNaf/vSn/OQnP+lyn+rqar71rW+xcOHCjB+3rxTuMaoZDjWHkq6iIHUWfpmEmHQs28EOqXB//PHHOw332tpa9u/fT1FRUaePcezYMQYM+HrEbd26lYaGhg7DvTcyCfckaFhGRPpk6NChAGzYsIE5c+awcOFCJk+ezKJFi2i70ltZWRk//vGPmTp1KlVVVTQ2NgKpHu26deu+9ljLli3j9ddfp6KiggceeOC457v66qv59NNPmTlzJnV1ddTU1LBixQoA5syZw+23305lZSUrV67kqaeeYsqUKZSXl3PxxRdz9OhR7r77burq6qioqKCuru5rv09zczNz5sxh0qRJ3HPPPe3tCxYsYObMmXzzm9+ktra2vc7Dhw9TUVHBokWLAFi7di3Tpk2jvLycm2++uf3+r732GhdccAFnnnnmcb9zrqjnLiJZ8/bbb7N9+3ZOP/10Zs+ezW9/+1suvPBCAIYPH867777L2rVruf3223nuuec6fZzly5ezYsWKDvepr69n6NChbN26FYCamprjth89erR9rqqpU6fy4osvMn78eA4ePMipp57Kvffe2+XQy1tvvcW2bdsYPHgw5557LldddRWVlZU8+uijjBo1isOHD3Puuedy3XXXsXz5clatWtVey/bt27nvvvvYtGkTY8aMYf/+/e2Pu3v3bjZu3Mh7773H1VdfnfMhGvXcRSRrqqqqKC0t5ZRTTqGiooKmpqb2bd/5znfaf77xxhs5q+Hb3/52+/Ls2bOprq7mF7/4BV9++WVG97/ssssYPXo0p512Gtdeey0bN24E4MEHH6S8vJxZs2bR3NzMzp07v3bfV155heuvv54xY8YAMGrUqPZtCxYs4JRTTuGcc85hz549ffkVM6Keu4hkzaBBg9qXi4qKOHbsWPt6+ul8bcsDBgzgq6++AuCrr77i6NGjfa5hyJAh7csPP/wwmzdv5vnnn2fmzJls2bKl2/ufeNqhmbFhwwZeeukl3njjDQYPHsycOXN6fN55+rFpG67KJfXcY1YzPOkK+r2yZc93epOeaRvfrqur4/zzzwdSY/FtgVtfX88XX3wBwLBhw/jkk0/6/JwffPAB5513Hvfeey8lJSU0Nzd3+9jr169n//79HD58mGeeeYbZs2d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IZc3gG2htu8pI9XF3UlfbymAW+H598G3B3azyTV8WwEngIG5aMeTT8gIhKh/jwsIyIinVC4i4hESOEuIhIhhbuISIQU7iIiEVK4i4hESOEuIhKh/wQAixDxpyEsLwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "m = torch.nn.BatchNorm1d(1, momentum=None)\n",
    "\n",
    "# input data (mean 10, var 25)\n",
    "x = 10+5*torch.randn(10000, 1)\n",
    "\n",
    "# first batch\n",
    "with torch.no_grad():\n",
    "    y = m(x)\n",
    "    \n",
    "plt.hist(x.numpy(),bins=50,label='input first batch');\n",
    "plt.hist(y.numpy(),bins=50,label='output first batch');\n",
    "plt.legend(loc='upper right');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d3270f2d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAhA0lEQVR4nO3df3RU1fnv8fcDAYKigPwqAhp6C9iWQIwhgigFKb8tqEWRWgWLUqtytb1qqV39mq5lu/ArV2q1UmkVgpUK8lWhaitiVVArmiCCigJ6QwmiBBTkh/x+7h9zkg4hIZNkQuacfF5rZc05++wzs/dM8mTPnn2eMXdHRESipVF9N0BERJJPwV1EJIIU3EVEIkjBXUQkghTcRUQiKK2+GwDQtm1bz8jIqO9miIiESmFh4TZ3b1fRsZQI7hkZGRQUFNR3M0REQsXMNlZ2TNMyIiIRpOAuIhJBCu4iIhGUEnPuFTl48CDFxcXs27evvpsiQnp6Op07d6ZJkyb13RSRhKRscC8uLuaUU04hIyMDM6vv5kgD5u5s376d4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
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# second batch (mean 110, var 25)\n",
    "# in eval mode\n",
    "m.eval()\n",
    "with torch.no_grad():\n",
    "    y_eval = m(100+x)\n",
    "# in train mode\n",
    "m.train()\n",
    "with torch.no_grad():\n",
    "    y_train = m(100+x)\n",
    "\n",
    "# third batch (mean 110, var 25)\n",
    "m.eval()\n",
    "with torch.no_grad():\n",
    "    y_eval_3 = m(100+x)\n",
    "    \n",
    "plt.hist(y_eval.numpy(),bins=50,label='output second batch eval');\n",
    "plt.hist(y_train.numpy(),bins=50,label='output second batch train');\n",
    "plt.hist(y_eval_3.numpy(),bins=50,label='output third batch eval');\n",
    "plt.ylim((0,850))\n",
    "plt.legend(loc='upper left');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1b764003",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "37ac74d1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "dldiy",
   "language": "python",
   "name": "dldiy"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
